/**
 * Created by Administrator on 2022/8/6.
 */
public class Demo {
    /*public static void main(String[] args) {
        //递归求 N 的阶乘
        int n = 3;
        int ret = fac(n);
        System.out.println(ret);
    }
    public static int fac(int n){
        if(n == 1){
            return 1;
        }else{
            return n * fac(n - 1);
        }
    }*/

    /*public static void main(String[] args) {
        //按顺序打印一个数字的每一位(例如 123 打印出 1 2 3)
        int num = 123;
        print(num);
    }
    public static void print(int num){
        if(num > 9){
            print(num / 10);
        }
        System.out.println(num % 10);
    }*/

    /*public static void main(String[] args) {
        //递归求 1 + 2 + 3 + ... + 10
        int n = 10;
        int ret = sum(n);
        System.out.println(ret);
    }
    public static int sum(int n){
        if(n == 1){
            return 1;
        }
        return n + sum(n - 1);
    }*/

    /*public static void main(String[] args) {
        //输入 1729, 则应该返回 1+7+2+9，它的和是19
        int n = 1729;
        int ret = sum(n);
        System.out.println(ret);
    }
    public static int sum(int n){
        if(n < 10){
            return n;
        }
        return n % 10 + sum(n / 10);
    }*/

    public static void main(String[] args) {
        //求斐波那契数列的第 N 项
        int n = 7;
        int ret = fib(n);
        System.out.println(ret);
    }
    public static int fib(int n){
        if(n == 1 || n == 2){
            return 1;
        }
        return fib(n - 1) + fib(n - 2);
    }
}
